import axios from 'axios'
import { message } from 'antd'
export interface Res<T> {
  code: 'success' | 'fail'
  data: T
  message?: string
}
const instance = axios.create({
  baseURL: import.meta.env.VITE_APP_BASE_API,
})
instance.interceptors.response.use((res) => {
  if (res.data.code !== 'success') {
    if (res.data.message) {
      message.error(res.data.message)
    }
  }
  return res
})
export const streamInstance = axios.create({
  baseURL: import.meta.env.VITE_APP_BASE_API,
  responseType: 'stream',
})
export default instance
